SELCOPY Version 1.1a Copyright Mike Price 1993-1994 SELCOPY is a general purpose DOS utility to enable the easy extraction and manipulation of records from a file. As the name suggests you can select and copy records. This program was devloped from a need to manipulate files that had been downloaded from a Mainframe. Parameters may be entered directly after starting the SELCOPY program or may be piped in using the < symbol. eg: SELCOPY < parm.dat. To start SELCOPY set the default drive/directory to that which contains the SELCOPY.EXE file and type SELCOPY * from the DOS prompt. This directory should also contain the SELCOPY.INI file. Using a limited set of commands it is very simple to select and edit records. The SEL statement allows you to set selection criteria whilst the OUT statement lets you define how the output record should look. You can either just copy the selected record from input file to output file or you can perform some simple manipulation. eg. Input record: 003001234231157BOB SMITH This input record is made up of an account number, 9 characters, a Date of Birth in the form DDMMYY, for 6 characters and a name, 9 characters. If we wanted the output record to contain only the Date of Birth, in the format YYMMDD, and the name, the SELCOPY commands would be as follows: INFILE="input filename" OUTFILE="output filename" OUT=0,13(2) OUT=2,11(2) OUT=4,9(2) OUT=6,15(9) END Because no SEL statements were used all records will be read from the input file. See the following pages for a detailed descritpion of the SELCOPY commands. NOTE: This version of SELCOPY has been compiled for 386 processors and above. If you require a version for either 8088/8086 or 286 processors send you request via either CompuServe or fax. Software registration fee is US$20. New versions will contain a sort and report feature. There are also plans for EBCDIC to ASCII conversion. Let's have a look at the parameters that can be used: Input file definition: INFILE=[filename][,LEN=NNNN] [,CR] [,LF] [,CRLF] ** Default ** Output file definition: OUTFILE=[filename][,LEN=NNNN] [,CR] [,LF] [,CRLF] ** Default is equal to INFILE value** Selection criteria: SEL=displacement(len), [=]"value"[,"value"] [#] [<] [>] [I] [E] Multiple "values" on same SEL statement are treated as OR conditions. Multiple SEL statements are treated as AND conditions. Output record definition: OUT=IN ** Default should OUTFILE exist ** This copies the whole input record to output. and/or OUT=outdisplacement,indisplacement(len) This selects data from the specified displacement in the input record and moves it to the specified displacement in the output record. and/or OUT=outdisplacement,"text" This moves fixed text to the specified displacement in the output record. Specify The Number of Records to be Output: COUNT=nnnnnnn Where nnnnnnn indicates the maximum number of records to be output. SKIP=nnnnnnn Where nnnnnnn indicates the maximum number of records to be read before processing is to begin. Display of Selected Records: DISPLAY This parameter enables selected records to be displayed. Print Selected Records: PRINT=[CHAR] This parameter enables the printing of selected records to the file specified in SELCOPY.INI or to SELCOPY.PRN in the default directory if no file is specified. END This defines the end of parameters. The maximum record length that can be processed with this version is 4096 bytes. The maximum variable length that may be used in the commands is 35 bytes. The maximum number of SEL and OUT statements is 20. SELCOPY requires a file SELCOPY.INI to be in the default directory. An example of the INI file is shown below: PRINTER INIT=1b266c3236411b266b32531b266c3844 PRINTER RESET=1b45 LINES/PAGE=66 PRINT FILE=SELCOPY.TST PRINTER INIT= This contains the printer initialisation string, in HEX. The above example is for a Panasonic KX-P4430. This sets page orientation to portrait, page length to 66 and 16.6 cpi. PRINTER RESET= This contains the printer reset string, in HEX. LINES/PAGE= Self explanatory. PRINT FILE= This specifies the name of the file for any printed output. If no file name is specified the default is SELCOPY.PRN IMPORTANT: As this is the first cut of SELCOPY, the INI file processing is not very sophisticated. Therefore all 4 lines MUST be present in the above sequence. Example 1: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" SEL=0(3),="rem" OUT=IN END Example 1 reads in the file AUTOEXEC.BAT from the root directory of the C: drive. Selects all records where the first 3 bytes are equal to lower case "rem" and outputs these records to the file "FRED" in the default directory. Example 2: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" SEL=0(3),="rem" OUT=0,4(20) END Example 2 is the same as example 1 except the output record consists only of 20 bytes copied from position 4 of the input record. If the input record length is less than 23 bytes long then only those bytes that are available are copied and the output record is padded with spaces. Example 3: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" SEL=0(3),="rem" OUT=0,"Remarks " OUT=8,0(20) END Example 3 is the same as example 1 except the output record consists of the constant "Remarks " followed by the first 20 bytes of the input record. Example 4: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" SEL=0(3),="rem" OUT=0,"Remarks " OUT=8,0(20) DISPLAY COUNT=4 END Example 4 is the same as example 3 except that the selected records will be display on the screen and only 4 records will be written to the output file. Example 5: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" OUT=IN DISPLAY COUNT=10 END Example 5 shows how to create an output file containing only the first 10 records from the input file and to display the selected records. Example 6: INFILE="C:\AUTOEXEC.BAT" OUTFILE="FRED" SEL=0(3),="rem","abc" OUT=IN COUNT=10 END Example 6 shows how to create an output file containing only 10 records from the input file. These ten records will be selected if they contain either "rem" or "abc" in the first 3 character positions. The selected records will not be displayed. Example 7: INFILE="C:\NAMEADDR.DAT" OUTFILE="LIMITED.CO" SEL=10(30),I"LTD","LIMITED" OUT=IN END Example 7 shows how to create an output file containing only records from the input file that have either the words LTD or LIMITED contained within the input record positions 11 thru 31. Example 8: INFILE="C:\NAMEADDR.DAT" OUTFILE="NOTLTD.CO" SEL=10(30),E"LTD","LIMITED" OUT=IN END Example 8 is the reverse of example 7. This shows how to create an output file containing only records from the input file that do not have either the words LTD or LIMITED contained within the input record positions 11 thru 31. SELCOPY Version 1.1a Copyright Mike Price 1993-1994 This is a Shareware Version of SELCOPY. To order a registered version, Mike maybe contacted via CompuServe 100033,2100 or by Fax on +64 4 473 0699